package com.jzo2o.customer.controller.operation;

import com.jzo2o.common.model.PageResult;
import com.jzo2o.customer.model.dto.request.WorkerCertificationAuditPageQueryReqDTO;
import com.jzo2o.customer.model.dto.response.WorkerCertificationAuditResDTO;
import com.jzo2o.customer.service.IWorkerCertificationAuditService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author itcast
 */
@RestController("operationWorkerCertificationAuditController")
@RequestMapping("/operation/worker-certification-audit")
@Api(tags = "运营端 - 运营端审核认证接口")
public class WorkerCertificationAuditController {

    @Resource
    private IWorkerCertificationAuditService workerCertificationAuditService;

    /**
     * 4.2.3.1. 审核服务人员认证分页查询
     */
    @GetMapping("/page")
    @ApiOperation("审核服务人员认证分页查询")
    public PageResult<WorkerCertificationAuditResDTO> page(WorkerCertificationAuditPageQueryReqDTO workerCertificationAuditPageQueryReqDTO) {
        return workerCertificationAuditService.pageWorkerCertificationAudit(workerCertificationAuditPageQueryReqDTO);
    }

    /**
     * 4.2.3.2 审核服务人员认证信息
     */
    @PutMapping("/audit/{id}")
    @ApiOperation("审核服务人员认证分页查询")
    public void audit(@PathVariable("id") Long id,
                      @RequestParam("certificationStatus") Integer certificationStatus,
                      @RequestParam(value = "rejectReason", required = false) String rejectReason) {
        if (rejectReason == null) {
            rejectReason = "";
        }
        workerCertificationAuditService.audit(id,certificationStatus,rejectReason);
    }
}
